class A(object):
    name="A"
    def __init__(self,sex):  
        self.sex=sex
class B(A):
    pass
a = A('man')
b = B('man')
print(hasattr(A,'sex'))           #False
print(hasattr(a,'name'))          #True
print(hasattr(a,'sex'))           #True
print(hasattr(b,'name'))          #True
print(hasattr(b,'sex'))           #True
print(hasattr(B,'name'))          #True
#子类、类的实例和子类的实例能访问父类的类属性。类并没有__init__()的“参数属性”，需要在实例中实现这样的属性
setattr(B,'old',18)
print(hasattr(b,'old'))           #True
print(hasattr(B,'old'))           #True
del B.old
print(hasattr(b,'old'))           #False
#实例生成后，能访问类新增的属性。实例应该继承父类全部属性。